package cn.com.pxto.commons.propertiesutil;

/**
 * @author prewind
 * Created on 2004-8-11
 */
public class Properties {
	public static String GLOBAL_CONF_FILE_NAME="/globalconf.properties";
	private static Properties properties = null;
	private Configuration config = null;

	private Properties() {
	}
	/**
	 * Properties��̬����
	 * @return GlobalConf
	 * @throws ConfigurationException �޷�����Properties
	 */
	public static Properties getInstance() throws ConfigurationException{
		if (properties == null) {
			properties = new Properties();
			properties.config = new Configuration(GLOBAL_CONF_FILE_NAME);
		}
		return properties;
	}

	public String getValue(String key,String defalutValue) {
		return config.getValue(key,defalutValue);
	}
	
	public String getValue(String key) {
		return config.getValue(key);
	}
	
	public int getIntValue(String key,int defaultValue) {
		int value = 0;
		value = Integer.parseInt(getValue(key,""+defaultValue));
		return value;
	}

	public int getIntValue(String key) {
		int value = 0;
		value = Integer.parseInt(getValue(key));
		return value;
	}
	
	public void setValue(String key, String value) throws ConfigurationException {
		config.setValue(key, value);
		config.saveFile();
	}
}